# Load Necessary Packages
library(Hmisc)

# Load Datasets
setwd("/users/josephphillips/Dropbox/COVID-19/Data/FC Data Repository")
usa <- read.csv("USA.csv",header=T,sep=",")
uk <- read.csv("UK.csv",header=T,sep=",")
canada <- read.csv("Canada 1.csv",header=T,sep=",")
canada2 <- read.csv("Canada 2.csv",header=T,sep=",")

# Table B1, US
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$target_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$target_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_target_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_target_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_target_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_target_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_target_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_target_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$nontarget_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$nontarget_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_nontarget_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_nontarget_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_nontarget_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_nontarget_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_nontarget_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_nontarget_false,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$nontarget_true,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$nontarget_true,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_nontarget_true,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_nontarget_true,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_nontarget_true,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_nontarget_true,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_nontarget_true,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_nontarget_true,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))

# Table B1, UK
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$targeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$targeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_targeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_targeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_targeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_targeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$nontargeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$nontargeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_nontargeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_nontargeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_nontargeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_nontargeted_false,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$nontargeted_true,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$nontargeted_true,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_nontargeted_true,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_nontargeted_true,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_nontargeted_true,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_nontargeted_true,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))

# Table B1, Canada 1
mean(subset(canada,canada$treat==0)$targeted_false,na.rm=T)
sd(subset(canada,canada$treat==0)$targeted_false,na.rm=T)
mean(subset(canada,canada$treat==0)$nontargeted_false,na.rm=T)
sd(subset(canada,canada$treat==0)$nontargeted_false,na.rm=T)
mean(subset(canada,canada$treat==0)$nontargeted_true,na.rm=T)
sd(subset(canada,canada$treat==0)$nontargeted_true,na.rm=T)

# Table B1, Canada 2
mean(subset(canada2,treat==0)$targeted_false,na.rm=T)
sd(subset(canada2,treat==0)$targeted_false,na.rm=T)
mean(subset(canada2,treat==0)$nontargeted_false,na.rm=T)
sd(subset(canada2,treat==0)$nontargeted_false,na.rm=T)
mean(subset(canada2,treat==0)$nontargeted_true,na.rm=T)
sd(subset(canada2,treat==0)$nontargeted_true,na.rm=T)

# Table B2, US
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$accuracy_con_theory1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$accuracy_con_theory1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$accuracy_con_theory5,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$accuracy_con_theory5,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$accuracy_False1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$accuracy_False1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$accuracy_False4,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$accuracy_False4,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_accuracy_con_theory1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_accuracy_con_theory1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_accuracy_con_theory5,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_accuracy_con_theory5,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_accuracy_False1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_accuracy_False1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_accuracy_False4,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W2_accuracy_False4,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_accuracy_con_theory1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_accuracy_con_theory1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_accuracy_con_theory5,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_accuracy_con_theory5,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_accuracy_False1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_accuracy_False1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_accuracy_False4,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W3_accuracy_False4,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_accuracy_con_theory1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_accuracy_con_theory1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_accuracy_con_theory5,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_accuracy_con_theory5,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_accuracy_False1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_accuracy_False1,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_accuracy_False4,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$W4_accuracy_False4,subset(usa,usa$factcheck_treatment==0 & usa$W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T))

# Table B2, UK
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$accuracy_con_theory1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$accuracy_con_theory1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$accuracy_con_theory5,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$accuracy_con_theory5,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$accuracy_False1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$accuracy_False1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$accuracy_False4,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$accuracy_False4,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_accuracy_con_theory1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_accuracy_con_theory1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_accuracy_con_theory5,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_accuracy_con_theory5,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_accuracy_False1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_accuracy_False1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_accuracy_False4,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W2_accuracy_False4,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_accuracy_con_theory1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_accuracy_con_theory1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_accuracy_con_theory5,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_accuracy_con_theory5,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_accuracy_False1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_accuracy_False1,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))
weighted.mean(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_accuracy_False4,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T)
sqrt(wtd.var(subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$W3_accuracy_False4,subset(uk,uk$factcheck_treatment==0 & uk$W3factcheck_treatment==0)$weight,na.rm=T))

# Table B2, Canada 1
mean(subset(canada,canada$treat==0)$accuracy_con_theory1,na.rm=T)
sd(subset(canada,canada$treat==0)$accuracy_con_theory1,na.rm=T)
mean(subset(canada,canada$treat==0)$accuracy_con_theory5,na.rm=T)
sd(subset(canada,canada$treat==0)$accuracy_con_theory5,na.rm=T)
mean(subset(canada,canada$treat==0)$accuracy_False1,na.rm=T)
sd(subset(canada,canada$treat==0)$accuracy_False1,na.rm=T)
mean(subset(canada,canada$treat==0)$accuracy_False4,na.rm=T)
sd(subset(canada,canada$treat==0)$accuracy_False4,na.rm=T)

# Table B2, Canada 2
mean(subset(canada2,canada2$treat==0)$accuracy_con_theory1,na.rm=T)
sd(subset(canada2,canada2$treat==0)$accuracy_con_theory1,na.rm=T)
mean(subset(canada2,canada2$treat==0)$accuracy_con_theory5,na.rm=T)
sd(subset(canada2,canada2$treat==0)$accuracy_con_theory5,na.rm=T)
mean(subset(canada2,canada2$treat==0)$accuracy_False1,na.rm=T)
sd(subset(canada2,canada2$treat==0)$accuracy_False1,na.rm=T)
mean(subset(canada2,canada2$treat==0)$accuracy_False4,na.rm=T)
sd(subset(canada2,canada2$treat==0)$accuracy_False4,na.rm=T)

# Table B3, USA
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$accuracy_con_theory1>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$accuracy_con_theory5>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$accuracy_False1>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$accuracy_False4>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W2_accuracy_con_theory1>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W2_accuracy_con_theory5>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W2_accuracy_False1>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W2_accuracy_False4>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W3_accuracy_con_theory1>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W3_accuracy_con_theory5>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W3_accuracy_False1>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W3_accuracy_False4>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W4_accuracy_con_theory1>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W4_accuracy_con_theory5>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W4_accuracy_False1>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$W4_accuracy_False4>2,1,0),subset(usa,factcheck_treatment==0 & W3factcheck_treatment==0)$weight_genpop_pulse_high_inciden,na.rm=T)

# Table B3, UK
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$accuracy_con_theory1>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$accuracy_con_theory5>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$accuracy_False1>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$accuracy_False4>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$W2_accuracy_con_theory1>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$W2_accuracy_con_theory5>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$W2_accuracy_False1>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$W2_accuracy_False4>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$W3_accuracy_con_theory1>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$W3_accuracy_con_theory5>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$W3_accuracy_False1>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)
weighted.mean(ifelse(subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$W3_accuracy_False4>1,1,0),subset(uk,factcheck_treatment==0 & W3factcheck_treatment==0)$weight,na.rm=T)

# Table B3, Canada 1
mean(ifelse(subset(canada,canada$treat==0)$accuracy_con_theory1>2,1,0),na.rm=T)
mean(ifelse(subset(canada,canada$treat==0)$accuracy_con_theory5>2,1,0),na.rm=T)
mean(ifelse(subset(canada,canada$treat==0)$accuracy_False1>2,1,0),na.rm=T)
mean(ifelse(subset(canada,canada$treat==0)$accuracy_False4>2,1,0),na.rm=T)

# Table B3, Canada 2
mean(ifelse(subset(canada2,canada2$treat==0)$accuracy_con_theory1>2,1,0),na.rm=T)
mean(ifelse(subset(canada2,canada2$treat==0)$accuracy_con_theory5>2,1,0),na.rm=T)
mean(ifelse(subset(canada2,canada2$treat==0)$accuracy_False1>2,1,0),na.rm=T)
mean(ifelse(subset(canada2,canada2$treat==0)$accuracy_False4>2,1,0),na.rm=T)

# Table B4
weighted.mean(usa$college,usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$agegroup=="Age 18-34",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$agegroup=="Age 35-44",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$agegroup=="Age 45-54",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$agegroup=="Age 55-64",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$agegroup=="Age 65+",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(usa$male,usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(usa$married,usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(usa$frequent_church,usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$region=="Northeast",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$region=="Midwest",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$region=="South",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(ifelse(usa$region=="West",1,0),usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(usa$democrat,usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(usa$republican,usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(usa$ideo7,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$ideo7,usa$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(usa$lives_highincidence,usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(usa$crt,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$crt,usa$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(usa$knowledge,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$knowledge,usa$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(usa$nonwhite,usa$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(usa$polinterest,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$polinterest,usa$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(usa$conspiracy,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$conspiracy,usa$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(usa$health_trust,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$health_trust,usa$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(usa$media_trust,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$media_trust,usa$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(usa$approve_trmp,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$approve_trmp,usa$weight_genpop_pulse_high_inciden,na.rm=T))
weighted.mean(usa$therm_trump,usa$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(usa$therm_trump,usa$weight_genpop_pulse_high_inciden,na.rm=T))

# Table B5
weighted.mean(uk$university,uk$weight,na.rm=T)
weighted.mean(ifelse(uk$agegroup=="age18-34",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$agegroup=="age35-44",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$agegroup=="age45-54",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$agegroup=="age55-64",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$agegroup=="age65+",1,0),uk$weight,na.rm=T)
weighted.mean(uk$male,uk$weight,na.rm=T)
weighted.mean(uk$married,uk$weight,na.rm=T)
weighted.mean(uk$frequentchurch,uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="North East",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="North West",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="Yorkshire and the Humber",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="East Midlands",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="West Midlands",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="East of England",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="London",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="South East",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="South West",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="Wales",1,0),uk$weight,na.rm=T)
weighted.mean(ifelse(uk$profile_GOR=="Scotland",1,0),uk$weight,na.rm=T)
weighted.mean(uk$left,uk$weight,na.rm=T)
weighted.mean(uk$right,uk$weight,na.rm=T)
weighted.mean(uk$ideology1,uk$weight,na.rm=T)
sqrt(wtd.var(uk$ideology1,uk$weight,na.rm=T))
weighted.mean(uk$lives_highincidence,uk$weight,na.rm=T)
weighted.mean(uk$knowledge,uk$weight,na.rm=T)
sqrt(wtd.var(uk$knowledge,uk$weight,na.rm=T))
weighted.mean(uk$nonwhite,uk$weight,na.rm=T)
weighted.mean(uk$polinterest,uk$weight,na.rm=T)
sqrt(wtd.var(uk$polinterest,uk$weight,na.rm=T))
weighted.mean(uk$conspiracy_general,uk$weight,na.rm=T)
sqrt(wtd.var(uk$conspiracy_general,uk$weight,na.rm=T))
weighted.mean(uk$trust_healthgov,uk$weight,na.rm=T)
sqrt(wtd.var(uk$trust_healthgov,uk$weight,na.rm=T))
weighted.mean(uk$total_media_trust,uk$weight,na.rm=T)
sqrt(wtd.var(uk$total_media_trust,uk$weight,na.rm=T))
weighted.mean(uk$approve_Boris,uk$weight,na.rm=T)
sqrt(wtd.var(uk$approve_Boris,uk$weight,na.rm=T))
weighted.mean(uk$therm_boris,uk$weight,na.rm=T)
sqrt(wtd.var(uk$therm_boris,uk$weight,na.rm=T))

# Table B6
mean(canada$university,na.rm=T)
summary(as.factor(canada$agegroup))
mean(canada$male,na.rm=T)
mean(canada$married,na.rm=T)
mean(canada$frequentchurch,na.rm=T)
summary(as.factor(canada$region))
mean(canada$left,na.rm=T)
mean(canada$right,na.rm=T)
mean(canada$ideology1,na.rm=T)
sd(canada$ideology1,na.rm=T)
mean(canada$knowledge,na.rm=T)
sd(canada$knowledge,na.rm=T)
mean(canada$nonwhite,na.rm=T)
mean(canada$polinterest,na.rm=T)
sd(canada$polinterest,na.rm=T)
mean(canada$conspiracy,na.rm=T)
sd(canada$conspiracy,na.rm=T)
mean(canada$trust_healthgov,na.rm=T)
sd(canada$trust_healthgov,na.rm=T)
mean(canada$total_media_trust,na.rm=T)
sd(canada$total_media_trust,na.rm=T)
mean(canada$approve_trudeau,na.rm=T)
sd(canada$approve_trudeau,na.rm=T)
mean(canada$trudeau_therm,na.rm=T)
sd(canada$trudeau_therm,na.rm=T)

# Table B7
mean(canada2$university,na.rm=T)
summary(as.factor(canada2$agegroup))
mean(canada2$male,na.rm=T)
mean(canada2$married,na.rm=T)
mean(canada2$frequentchurch,na.rm=T)
summary(as.factor(canada2$region))
mean(canada2$left,na.rm=T)
mean(canada2$right,na.rm=T)
mean(canada2$ideology1,na.rm=T)
sd(canada2$ideology1,na.rm=T)
mean(canada2$knowledge,na.rm=T)
sd(canada2$knowledge,na.rm=T)
mean(canada2$nonwhite,na.rm=T)
mean(canada2$polinterest,na.rm=T)
sd(canada2$polinterest,na.rm=T)
mean(canada2$conspiracy,na.rm=T)
sd(canada2$conspiracy,na.rm=T)
mean(canada2$trust_healthgov,na.rm=T)
sd(canada2$trust_healthgov,na.rm=T)
mean(canada2$total_media_trust,na.rm=T)
sd(canada2$total_media_trust,na.rm=T)
mean(canada2$approve_trudeau,na.rm=T)
sd(canada2$approve_trudeau,na.rm=T)
mean(canada2$trudeau_therm,na.rm=T)
sd(canada2$trudeau_therm,na.rm=T)